# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -O0 -mtriple=aarch64-unknown-unknown -verify-machineinstrs -global-isel-abort=0 -run-pass=legalizer %s -o - | FileCheck %s
---
name:            legalize_phi
alignment:       4
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
tracksRegLiveness: true
registers:
  - { id: 0, class: _, preferred-register: '' }
  - { id: 1, class: _, preferred-register: '' }
  - { id: 2, class: _, preferred-register: '' }
  - { id: 3, class: _, preferred-register: '' }
  - { id: 4, class: _, preferred-register: '' }
  - { id: 5, class: _, preferred-register: '' }
  - { id: 6, class: _, preferred-register: '' }
  - { id: 7, class: _, preferred-register: '' }
  - { id: 8, class: _, preferred-register: '' }
  - { id: 9, class: _, preferred-register: '' }
  - { id: 10, class: _, preferred-register: '' }
liveins:
body:             |
  ; CHECK-LABEL: name: legalize_phi
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
  ; CHECK:   liveins: $w0
  ; CHECK:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
  ; CHECK:   [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
  ; CHECK:   [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
  ; CHECK:   G_BRCOND [[TRUNC]](s1), %bb.1
  ; CHECK:   G_BR %bb.2
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.3(0x80000000)
  ; CHECK:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
  ; CHECK:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
  ; CHECK:   G_BR %bb.3
  ; CHECK: bb.2:
  ; CHECK:   successors: %bb.3(0x80000000)
  ; CHECK:   [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
  ; CHECK:   [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
  ; CHECK: bb.3:
  ; CHECK:   [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
  ; CHECK:   [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
  ; CHECK:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
  ; CHECK:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
  ; CHECK:   $w0 = COPY [[AND]](s32)
  ; CHECK:   RET_ReallyLR implicit $w0
  bb.0:
   ; Test that we insert legalization artifacts(Truncs here) into the correct BBs
   ; while legalizing the G_PHI to s16.


    successors: %bb.1(0x40000000), %bb.2(0x40000000)
    liveins: $w0

    %0(s32) = COPY $w0
    %1(s32) = G_CONSTANT i32 0
    %3(s32) = G_CONSTANT i32 1
    %6(s32) = G_CONSTANT i32 2
    %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
    G_BRCOND %2(s1), %bb.1
    G_BR %bb.2

  bb.1:
    successors: %bb.3(0x80000000)

    %4(s32) = G_ADD %0, %3
    %5(s1) = G_TRUNC %4(s32)
    G_BR %bb.3

  bb.2:
    successors: %bb.3(0x80000000)

    %7(s32) = G_ADD %0, %6
    %8(s1) = G_TRUNC %7(s32)

  bb.3:
    %9(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
    %11:_(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
    %10(s32) = G_ZEXT %9(s1)
    $w0 = COPY %10(s32)
    RET_ReallyLR implicit $w0

...
---
name:            legalize_phi_ptr
alignment:       4
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
tracksRegLiveness: true
registers:
  - { id: 0, class: _, preferred-register: '' }
  - { id: 1, class: _, preferred-register: '' }
  - { id: 2, class: _, preferred-register: '' }
  - { id: 3, class: _, preferred-register: '' }
  - { id: 4, class: _, preferred-register: '' }
  - { id: 5, class: _, preferred-register: '' }
liveins:
body:             |
  ; CHECK-LABEL: name: legalize_phi_ptr
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
  ; CHECK:   liveins: $w2, $x0, $x1
  ; CHECK:   [[COPY:%[0-9]+]]:_(p0) = COPY $x0
  ; CHECK:   [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
  ; CHECK:   [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[COPY2]](s32)
  ; CHECK:   G_BRCOND [[TRUNC]](s1), %bb.1
  ; CHECK:   G_BR %bb.2
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.2(0x80000000)
  ; CHECK: bb.2:
  ; CHECK:   [[PHI:%[0-9]+]]:_(p0) = G_PHI [[COPY]](p0), %bb.0, [[COPY1]](p0), %bb.1
  ; CHECK:   $x0 = COPY [[PHI]](p0)
  ; CHECK:   RET_ReallyLR implicit $x0
  bb.1:

    successors: %bb.2, %bb.3
    liveins: $w2, $x0, $x1

    %0(p0) = COPY $x0
    %1(p0) = COPY $x1
    %4(s32) = COPY $w2
    %2(s1) = G_TRUNC %4(s32)
    G_BRCOND %2(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors: %bb.3

  bb.3:
    %3(p0) = G_PHI %0(p0), %bb.1, %1(p0), %bb.2
    $x0 = COPY %3(p0)
    RET_ReallyLR implicit $x0

...
---
name:            legalize_phi_empty
alignment:       4
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
tracksRegLiveness: true
registers:
  - { id: 0, class: _, preferred-register: '' }
  - { id: 1, class: _, preferred-register: '' }
  - { id: 2, class: _, preferred-register: '' }
  - { id: 3, class: _, preferred-register: '' }
  - { id: 4, class: _, preferred-register: '' }
  - { id: 5, class: _, preferred-register: '' }
  - { id: 6, class: _, preferred-register: '' }
  - { id: 7, class: _, preferred-register: '' }
  - { id: 8, class: _, preferred-register: '' }
  - { id: 9, class: _, preferred-register: '' }
  - { id: 10, class: _, preferred-register: '' }
liveins:
body:             |
  ; CHECK-LABEL: name: legalize_phi_empty
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
  ; CHECK:   liveins: $w0
  ; CHECK:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
  ; CHECK:   [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
  ; CHECK:   [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
  ; CHECK:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
  ; CHECK:   G_BRCOND [[TRUNC]](s1), %bb.1
  ; CHECK:   G_BR %bb.2
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.3(0x80000000)
  ; CHECK:   [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
  ; CHECK:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
  ; CHECK:   G_BR %bb.3
  ; CHECK: bb.2:
  ; CHECK:   successors: %bb.3(0x80000000)
  ; CHECK:   [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
  ; CHECK: bb.3:
  ; CHECK:   [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
  ; CHECK:   [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
  ; CHECK:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
  ; CHECK:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
  ; CHECK:   $w0 = COPY [[AND]](s32)
  ; CHECK:   RET_ReallyLR implicit $w0
  bb.0:
    successors: %bb.1(0x40000000), %bb.2(0x40000000)
    liveins: $w0
   ; Test that we properly legalize a phi with a predecessor that's empty




    %0(s32) = COPY $w0
    %1(s32) = G_CONSTANT i32 0
    %3(s32) = G_CONSTANT i32 3
    %6(s32) = G_CONSTANT i32 1
    %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
    %4(s32) = G_ADD %0, %3
    %5(s1) = G_TRUNC %4(s32)
    G_BRCOND %2(s1), %bb.1
    G_BR %bb.2

  bb.1:
    successors: %bb.3(0x80000000)

    %7(s32) = G_ADD %0, %6
    %8(s1) = G_TRUNC %7(s32)
    G_BR %bb.3

  bb.2:
    successors: %bb.3(0x80000000)


  bb.3:
    %9(s1) = G_PHI %8(s1), %bb.1, %5(s1), %bb.2
    %10(s32) = G_ZEXT %9(s1)
    $w0 = COPY %10(s32)
    RET_ReallyLR implicit $w0

...
---
name:            legalize_phi_loop
alignment:       4
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
tracksRegLiveness: true
registers:
  - { id: 0, class: _, preferred-register: '' }
  - { id: 1, class: _, preferred-register: '' }
  - { id: 2, class: _, preferred-register: '' }
  - { id: 3, class: _, preferred-register: '' }
  - { id: 4, class: _, preferred-register: '' }
  - { id: 5, class: _, preferred-register: '' }
  - { id: 6, class: _, preferred-register: '' }
  - { id: 7, class: _, preferred-register: '' }
liveins:
body:             |
  ; CHECK-LABEL: name: legalize_phi_loop
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x80000000)
  ; CHECK:   liveins: $w0
  ; CHECK:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK:   [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
  ; CHECK:   [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %13(s16), %bb.1
  ; CHECK:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
  ; CHECK:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
  ; CHECK:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ANYEXT]], [[C1]]
  ; CHECK:   [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
  ; CHECK:   [[COPY1:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
  ; CHECK:   [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C2]]
  ; CHECK:   [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
  ; CHECK:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
  ; CHECK:   G_BRCOND [[TRUNC]](s1), %bb.1
  ; CHECK: bb.2:
  ; CHECK:   [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
  ; CHECK:   [[COPY2:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
  ; CHECK:   [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C3]]
  ; CHECK:   $w0 = COPY [[AND1]](s32)
  ; CHECK:   RET_ReallyLR implicit $w0
  bb.0:
    successors: %bb.1(0x80000000)
    liveins: $w0
   ; Test that we properly legalize a phi that uses a value from the same BB

    %0(s32) = COPY $w0
    %2(s8) = G_CONSTANT i8 1
    %7(s8) = G_CONSTANT i8 0

  bb.1:
    successors: %bb.1(0x40000000), %bb.3(0x40000000)

    %1(s8) = G_PHI %7(s8), %bb.0, %3(s8), %bb.1
    %3(s8) = G_ADD %1, %2
    %4(s32) = G_ZEXT %3(s8)
    %5(s1) = G_ICMP intpred(ugt), %4(s32), %0
    G_BRCOND %5(s1), %bb.1

  bb.3:
    %6(s32) = G_ZEXT %3(s8)
    $w0 = COPY %6(s32)
    RET_ReallyLR implicit $w0

...
---
name:            legalize_phi_cycle
alignment:       4
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
tracksRegLiveness: true
registers:
  - { id: 0, class: _, preferred-register: '' }
  - { id: 1, class: _, preferred-register: '' }
  - { id: 2, class: _, preferred-register: '' }
  - { id: 3, class: _, preferred-register: '' }
  - { id: 4, class: _, preferred-register: '' }
liveins:
body:             |
  ; CHECK-LABEL: name: legalize_phi_cycle
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x80000000)
  ; CHECK:   liveins: $w0
  ; CHECK:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK:   [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
  ; CHECK:   [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %7(s16), %bb.1
  ; CHECK:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
  ; CHECK:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
  ; CHECK:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C1]]
  ; CHECK:   [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
  ; CHECK:   [[COPY1:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
  ; CHECK:   G_BRCOND [[TRUNC]](s1), %bb.1
  ; CHECK: bb.2:
  ; CHECK:   $w0 = COPY [[AND]](s32)
  ; CHECK:   RET_ReallyLR implicit $w0
  bb.0:
    successors: %bb.1(0x80000000)
    liveins: $w0
   ; Test that we properly legalize a phi that uses itself


    %0(s32) = COPY $w0
    %4(s8) = G_CONSTANT i8 0

  bb.1:
    successors: %bb.1(0x40000000), %bb.3(0x40000000)

    %1(s8) = G_PHI %4(s8), %bb.0, %1(s8), %bb.1
    %2(s32) = G_ZEXT %1(s8)
    %3(s1) = G_ICMP intpred(ugt), %2(s32), %0
    G_BRCOND %3(s1), %bb.1

  bb.3:
    $w0 = COPY %2(s32)
    RET_ReallyLR implicit $w0

...
---
name:            legalize_phi_same_bb
alignment:       4
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
tracksRegLiveness: true
registers:
  - { id: 0, class: _, preferred-register: '' }
  - { id: 1, class: _, preferred-register: '' }
  - { id: 2, class: _, preferred-register: '' }
  - { id: 3, class: _, preferred-register: '' }
  - { id: 4, class: _, preferred-register: '' }
  - { id: 5, class: _, preferred-register: '' }
  - { id: 6, class: _, preferred-register: '' }
  - { id: 7, class: _, preferred-register: '' }
  - { id: 8, class: _, preferred-register: '' }
  - { id: 9, class: _, preferred-register: '' }
  - { id: 10, class: _, preferred-register: '' }
  - { id: 11, class: _, preferred-register: '' }
  - { id: 12, class: _, preferred-register: '' }
  - { id: 13, class: _, preferred-register: '' }
  - { id: 14, class: _, preferred-register: '' }
liveins:
body:             |
  ; CHECK-LABEL: name: legalize_phi_same_bb
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
  ; CHECK:   liveins: $w0
  ; CHECK:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
  ; CHECK:   [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
  ; CHECK:   [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
  ; CHECK:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
  ; CHECK:   G_BRCOND [[TRUNC]](s1), %bb.1
  ; CHECK:   G_BR %bb.2
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.3(0x80000000)
  ; CHECK:   [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
  ; CHECK:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
  ; CHECK:   [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
  ; CHECK:   G_BR %bb.3
  ; CHECK: bb.2:
  ; CHECK:   successors: %bb.3(0x80000000)
  ; CHECK:   [[C3:%[0-9]+]]:_(s16) = G_CONSTANT i16 42
  ; CHECK:   [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
  ; CHECK: bb.3:
  ; CHECK:   [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.1, [[TRUNC3]](s16), %bb.2
  ; CHECK:   [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[C3]](s16), %bb.2
  ; CHECK:   [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
  ; CHECK:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
  ; CHECK:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
  ; CHECK:   [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
  ; CHECK:   [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C4]]
  ; CHECK:   [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]]
  ; CHECK:   $w0 = COPY [[ADD2]](s32)
  ; CHECK:   RET_ReallyLR implicit $w0
  bb.0:
    successors: %bb.1(0x40000000), %bb.2(0x40000000)
    liveins: $w0
   ; Make sure that we correctly insert the new legalized G_PHI at the
   ; correct location (ie make sure G_PHIs are the first insts in the BB).




    %0(s32) = COPY $w0
    %1(s32) = G_CONSTANT i32 0
    %3(s32) = G_CONSTANT i32 3
    %6(s32) = G_CONSTANT i32 1
    %14(s8) = G_CONSTANT i8 42
    %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
    %4(s32) = G_ADD %0, %3
    %5(s8) = G_TRUNC %4(s32)
    G_BRCOND %2(s1), %bb.1
    G_BR %bb.2

  bb.1:
    successors: %bb.3(0x80000000)

    %7(s32) = G_ADD %0, %6
    %8(s8) = G_TRUNC %7(s32)
    G_BR %bb.3

  bb.2:
    successors: %bb.3(0x80000000)


  bb.3:
    %9(s8) = G_PHI %8(s8), %bb.1, %5(s8), %bb.2
    %10(s8) = G_PHI %8(s8), %bb.1, %14(s8), %bb.2
    %11(s32) = G_ZEXT %9(s8)
    %12(s32) = G_ZEXT %10(s8)
    %13(s32) = G_ADD %11, %12
    $w0 = COPY %13(s32)
    RET_ReallyLR implicit $w0

...
---
name:            legalize_phi_diff_bb
alignment:       4
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
tracksRegLiveness: true
registers:
  - { id: 0, class: _, preferred-register: '' }
  - { id: 1, class: _, preferred-register: '' }
  - { id: 2, class: _, preferred-register: '' }
  - { id: 3, class: _, preferred-register: '' }
  - { id: 4, class: _, preferred-register: '' }
  - { id: 5, class: _, preferred-register: '' }
  - { id: 6, class: _, preferred-register: '' }
  - { id: 7, class: _, preferred-register: '' }
  - { id: 8, class: _, preferred-register: '' }
  - { id: 9, class: _, preferred-register: '' }
  - { id: 10, class: _, preferred-register: '' }
  - { id: 11, class: _, preferred-register: '' }
  - { id: 12, class: _, preferred-register: '' }
  - { id: 13, class: _, preferred-register: '' }
  - { id: 14, class: _, preferred-register: '' }
  - { id: 15, class: _, preferred-register: '' }
liveins:
body:             |
  ; CHECK-LABEL: name: legalize_phi_diff_bb
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
  ; CHECK:   liveins: $w0, $w1
  ; CHECK:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
  ; CHECK:   [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
  ; CHECK:   [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 44
  ; CHECK:   [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
  ; CHECK:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
  ; CHECK:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
  ; CHECK:   [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
  ; CHECK:   G_BRCOND [[TRUNC]](s1), %bb.1
  ; CHECK:   G_BR %bb.2
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.2(0x40000000), %bb.1(0x40000000)
  ; CHECK:   [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.0, %21(s16), %bb.1
  ; CHECK:   [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
  ; CHECK:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
  ; CHECK:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
  ; CHECK:   [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[C2]]
  ; CHECK:   [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[ADD1]](s32), [[C3]]
  ; CHECK:   [[TRUNC3:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
  ; CHECK:   [[COPY2:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
  ; CHECK:   [[C5:%[0-9]+]]:_(s16) = G_CONSTANT i16 43
  ; CHECK:   G_BRCOND [[TRUNC3]](s1), %bb.2
  ; CHECK:   G_BR %bb.1
  ; CHECK: bb.2:
  ; CHECK:   [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[COPY2]](s16), %bb.1, [[TRUNC1]](s16), %bb.0
  ; CHECK:   [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
  ; CHECK:   [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
  ; CHECK:   [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C6]]
  ; CHECK:   $w0 = COPY [[AND1]](s32)
  ; CHECK:   RET_ReallyLR implicit $w0
  bb.0:
    successors: %bb.1(0x40000000), %bb.3(0x40000000)
    liveins: $w0, $w1
   ; Make sure that we correctly legalize PHIs sharing common defs
   ; in different BBs.



    %0(s32) = COPY $w0
    %1(s32) = COPY $w1
    %2(s32) = G_CONSTANT i32 0
    %4(s32) = G_CONSTANT i32 3
    %9(s32) = G_CONSTANT i32 1
    %11(s32) = G_CONSTANT i32 44
    %15(s8) = G_CONSTANT i8 43
    %3(s1) = G_ICMP intpred(ugt), %0(s32), %2
    %5(s32) = G_ADD %0, %4
    %6(s8) = G_TRUNC %5(s32)
    G_BRCOND %3(s1), %bb.1
    G_BR %bb.3

  bb.1:
    successors: %bb.3(0x40000000), %bb.1(0x40000000)

    %7(s8) = G_PHI %6(s8), %bb.0, %15(s8), %bb.1
    %8(s32) = G_ZEXT %7(s8)
    %10(s32) = G_ADD %8, %9
    %12(s1) = G_ICMP intpred(ugt), %10(s32), %11
    G_BRCOND %12(s1), %bb.3
    G_BR %bb.1

  bb.3:
    %13(s8) = G_PHI %7(s8), %bb.1, %6(s8), %bb.0
    %14(s32) = G_ZEXT %13(s8)
    $w0 = COPY %14(s32)
    RET_ReallyLR implicit $w0

...
---
name:            legalize_phi_check_insertpt
alignment:       4
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: legalize_phi_check_insertpt
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x80000000)
  ; CHECK:   liveins: $x0, $x1
  ; CHECK:   [[COPY:%[0-9]+]]:_(s64) = COPY $x0
  ; CHECK:   [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
  ; CHECK:   [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
  ; CHECK:   G_BR %bb.1
  ; CHECK: bb.1:
  ; CHECK:   [[PHI:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.0
  ; CHECK:   [[PHI1:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.0
  ; CHECK:   [[PHI2:%[0-9]+]]:_(s64) = G_PHI [[COPY]](s64), %bb.0
  ; CHECK:   [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[PHI]](s64), [[PHI1]](s64)
  ; CHECK:   G_STORE [[MV]](s128), [[COPY1]](p0) :: (store (s128))
  ; CHECK:   G_STORE [[PHI2]](s64), [[COPY1]](p0) :: (store (s64))
  ; CHECK:   RET_ReallyLR
  ; Check that the G_MERGE here gets inserted after all the PHIs.
  bb.0:
    successors: %bb.1(0x40000000)
    liveins: $x0, $x1

    %0:_(s64) = COPY $x0
    %1:_(p0) = COPY $x1
    %2:_(s128) = G_IMPLICIT_DEF
    G_BR %bb.1

  bb.1:
    %3:_(s128) = G_PHI %2(s128), %bb.0
    %4:_(s64) = G_PHI %0(s64), %bb.0
    G_STORE %3(s128), %1(p0) :: (store (s128))
    G_STORE %4(s64), %1(p0) :: (store (s64))
    RET_ReallyLR

...
---
name:            legalize_phi_vector
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: legalize_phi_vector
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x80000000)
  ; CHECK:   liveins: $q0, $x1
  ; CHECK:   [[COPY:%[0-9]+]]:_(<16 x s8>) = COPY $q0
  ; CHECK:   G_BR %bb.1
  ; CHECK: bb.1:
  ; CHECK:   [[PHI:%[0-9]+]]:_(<16 x s8>) = G_PHI [[COPY]](<16 x s8>), %bb.0
  ; CHECK:   $q0 = COPY [[PHI]](<16 x s8>)
  ; CHECK:   RET_ReallyLR
  bb.0:
    successors: %bb.1
    liveins: $q0, $x1

    %0:_(<16 x s8>) = COPY $q0
    G_BR %bb.1

  bb.1:
    %3:_(<16 x s8>) = G_PHI %0(<16 x s8>), %bb.0
    $q0 = COPY %3(<16 x s8>)
    RET_ReallyLR
...
---
name:             s88
tracksRegLiveness: true
liveins:
body:             |
  ; CHECK-LABEL: name: s88
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
  ; CHECK:   liveins: $x0
  ; CHECK:   %cond:_(s1) = G_IMPLICIT_DEF
  ; CHECK:   G_BRCOND %cond(s1), %bb.1
  ; CHECK:   G_BR %bb.2
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.3(0x80000000)
  ; CHECK:   [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
  ; CHECK:   G_BR %bb.3
  ; CHECK: bb.2:
  ; CHECK:   successors: %bb.3(0x80000000)
  ; CHECK:   [[DEF1:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
  ; CHECK: bb.3:
  ; CHECK:   [[PHI:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.1, [[DEF1]](s64), %bb.2
  ; CHECK:   $x0 = COPY [[PHI]](s64)
  ; CHECK:   RET_ReallyLR implicit $x0
  bb.0:
    successors: %bb.1(0x40000000), %bb.2(0x40000000)
    liveins: $x0
    %cond:_(s1) = G_IMPLICIT_DEF
    G_BRCOND %cond(s1), %bb.1
    G_BR %bb.2
  bb.1:
    successors: %bb.3(0x80000000)
    %imp_1:_(s88) = G_IMPLICIT_DEF
    G_BR %bb.3
  bb.2:
    successors: %bb.3(0x80000000)
    %imp_2:_(s88) = G_IMPLICIT_DEF
  bb.3:
    %phi:_(s88) = G_PHI %imp_1:_(s88), %bb.1, %imp_2:_(s88), %bb.2
    %trunc:_(s64) = G_TRUNC %phi
    $x0 = COPY %trunc
    RET_ReallyLR implicit $x0
...
---
name:            v4s64
alignment:       4
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: v4s64
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x50000000), %bb.2(0x30000000)
  ; CHECK:   liveins: $x0, $x1
  ; CHECK:   %ptr1:_(p0) = COPY $x1
  ; CHECK:   %ptr2:_(p0) = COPY $x0
  ; CHECK:   %cond:_(s1) = G_IMPLICIT_DEF
  ; CHECK:   [[LOAD:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr1(p0) :: (load (<2 x s64>), align 32)
  ; CHECK:   [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
  ; CHECK:   [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr1, [[C]](s64)
  ; CHECK:   [[LOAD1:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD]](p0) :: (load (<2 x s64>) from unknown-address + 16)
  ; CHECK:   G_BRCOND %cond(s1), %bb.2
  ; CHECK:   G_BR %bb.1
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.2(0x80000000)
  ; CHECK:   [[LOAD2:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr2(p0) :: (load (<2 x s64>), align 32)
  ; CHECK:   [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
  ; CHECK:   [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr2, [[C1]](s64)
  ; CHECK:   [[LOAD3:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD1]](p0) :: (load (<2 x s64>) from unknown-address + 16)
  ; CHECK: bb.2:
  ; CHECK:   [[PHI:%[0-9]+]]:_(<2 x s64>) = G_PHI [[LOAD2]](<2 x s64>), %bb.1, [[LOAD]](<2 x s64>), %bb.0
  ; CHECK:   [[PHI1:%[0-9]+]]:_(<2 x s64>) = G_PHI [[LOAD3]](<2 x s64>), %bb.1, [[LOAD1]](<2 x s64>), %bb.0
  ; CHECK:   $q0 = COPY [[PHI]](<2 x s64>)
  ; CHECK:   $q1 = COPY [[PHI1]](<2 x s64>)
  ; CHECK:   RET_ReallyLR implicit $q0, implicit $q1
  bb.0:
    successors: %bb.1(0x50000000), %bb.2(0x30000000)
    liveins: $x0, $x1

    %ptr1:_(p0) = COPY $x1
    %ptr2:_(p0) = COPY $x0
    %cond:_(s1) = G_IMPLICIT_DEF
    %val_1:_(<4 x s64>) = G_LOAD %ptr1(p0) :: (load (<4 x s64>))
    G_BRCOND %cond(s1), %bb.2
    G_BR %bb.1
  bb.1:
    %val_2:_(<4 x s64>) = G_LOAD %ptr2(p0) :: (load (<4 x s64>))
  bb.2:
    %phi:_(<4 x s64>) = G_PHI %val_2(<4 x s64>), %bb.1, %val_1(<4 x s64>), %bb.0
    %unmerge_1:_(<2 x s64>), %unmerge_2:_(<2 x s64>) = G_UNMERGE_VALUES %phi(<4 x s64>)
    $q0 = COPY %unmerge_1(<2 x s64>)
    $q1 = COPY %unmerge_2(<2 x s64>)
    RET_ReallyLR implicit $q0, implicit $q1
...
---
name:            v8s32
alignment:       4
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: v8s32
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x50000000), %bb.2(0x30000000)
  ; CHECK:   liveins: $x0, $x1
  ; CHECK:   %cond:_(s1) = G_IMPLICIT_DEF
  ; CHECK:   [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
  ; CHECK:   [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[DEF]](s32), [[DEF]](s32), [[DEF]](s32), [[DEF]](s32)
  ; CHECK:   [[BUILD_VECTOR1:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[DEF]](s32), [[DEF]](s32), [[DEF]](s32), [[DEF]](s32)
  ; CHECK:   G_BRCOND %cond(s1), %bb.2
  ; CHECK:   G_BR %bb.1
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.2(0x80000000)
  ; CHECK:   [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
  ; CHECK:   [[BUILD_VECTOR2:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[DEF1]](s32), [[DEF1]](s32), [[DEF1]](s32), [[DEF1]](s32)
  ; CHECK:   [[BUILD_VECTOR3:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[DEF1]](s32), [[DEF1]](s32), [[DEF1]](s32), [[DEF1]](s32)
  ; CHECK: bb.2:
  ; CHECK:   [[PHI:%[0-9]+]]:_(<4 x s32>) = G_PHI [[BUILD_VECTOR2]](<4 x s32>), %bb.1, [[BUILD_VECTOR]](<4 x s32>), %bb.0
  ; CHECK:   [[PHI1:%[0-9]+]]:_(<4 x s32>) = G_PHI [[BUILD_VECTOR3]](<4 x s32>), %bb.1, [[BUILD_VECTOR1]](<4 x s32>), %bb.0
  ; CHECK:   %one:_(s32) = G_CONSTANT i32 1
  ; CHECK:   [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
  ; CHECK:   %extract:_(s32) = G_EXTRACT_VECTOR_ELT [[PHI]](<4 x s32>), [[C]](s64)
  ; CHECK:   $w0 = COPY %extract(s32)
  ; CHECK:   RET_ReallyLR implicit $w0
  bb.0:
    successors: %bb.1(0x50000000), %bb.2(0x30000000)
    liveins: $x0, $x1
    %cond:_(s1) = G_IMPLICIT_DEF
    %val_1:_(<8 x s32>) = G_IMPLICIT_DEF
    G_BRCOND %cond(s1), %bb.2
    G_BR %bb.1
  bb.1:
    %val_2:_(<8 x s32>) = G_IMPLICIT_DEF
  bb.2:
    %phi:_(<8 x s32>) = G_PHI %val_2(<8 x s32>), %bb.1, %val_1(<8 x s32>), %bb.0
    %one:_(s32) = G_CONSTANT i32 1
    %extract:_(s32) = G_EXTRACT_VECTOR_ELT %phi(<8 x s32>), %one(s32)
    $w0 = COPY %extract
    RET_ReallyLR implicit $w0
...
---
name:            v16s16
alignment:       4
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: v16s16
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x50000000), %bb.2(0x30000000)
  ; CHECK:   liveins: $x0, $x1
  ; CHECK:   %cond:_(s1) = G_IMPLICIT_DEF
  ; CHECK:   [[DEF:%[0-9]+]]:_(s16) = G_IMPLICIT_DEF
  ; CHECK:   [[BUILD_VECTOR:%[0-9]+]]:_(<8 x s16>) = G_BUILD_VECTOR [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16)
  ; CHECK:   [[BUILD_VECTOR1:%[0-9]+]]:_(<8 x s16>) = G_BUILD_VECTOR [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16), [[DEF]](s16)
  ; CHECK:   G_BRCOND %cond(s1), %bb.2
  ; CHECK:   G_BR %bb.1
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.2(0x80000000)
  ; CHECK:   [[DEF1:%[0-9]+]]:_(s16) = G_IMPLICIT_DEF
  ; CHECK:   [[BUILD_VECTOR2:%[0-9]+]]:_(<8 x s16>) = G_BUILD_VECTOR [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16)
  ; CHECK:   [[BUILD_VECTOR3:%[0-9]+]]:_(<8 x s16>) = G_BUILD_VECTOR [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16), [[DEF1]](s16)
  ; CHECK: bb.2:
  ; CHECK:   [[PHI:%[0-9]+]]:_(<8 x s16>) = G_PHI [[BUILD_VECTOR2]](<8 x s16>), %bb.1, [[BUILD_VECTOR]](<8 x s16>), %bb.0
  ; CHECK:   [[PHI1:%[0-9]+]]:_(<8 x s16>) = G_PHI [[BUILD_VECTOR3]](<8 x s16>), %bb.1, [[BUILD_VECTOR1]](<8 x s16>), %bb.0
  ; CHECK:   %one:_(s16) = G_CONSTANT i16 1
  ; CHECK:   [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
  ; CHECK:   %extract:_(s16) = G_EXTRACT_VECTOR_ELT [[PHI]](<8 x s16>), [[C]](s64)
  ; CHECK:   $h0 = COPY %extract(s16)
  ; CHECK:   RET_ReallyLR implicit $h0
  bb.0:
    successors: %bb.1(0x50000000), %bb.2(0x30000000)
    liveins: $x0, $x1
    %cond:_(s1) = G_IMPLICIT_DEF
    %val_1:_(<16 x s16>) = G_IMPLICIT_DEF
    G_BRCOND %cond(s1), %bb.2
    G_BR %bb.1
  bb.1:
    %val_2:_(<16 x s16>) = G_IMPLICIT_DEF
  bb.2:
    %phi:_(<16 x s16>) = G_PHI %val_2(<16 x s16>), %bb.1, %val_1(<16 x s16>), %bb.0
    %one:_(s16) = G_CONSTANT i16 1
    %extract:_(s16) = G_EXTRACT_VECTOR_ELT %phi(<16 x s16>), %one(s16)
    $h0 = COPY %extract
    RET_ReallyLR implicit $h0
...
---
name:            v32s8
alignment:       4
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: v32s8
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x50000000), %bb.2(0x30000000)
  ; CHECK:   liveins: $x0, $x1
  ; CHECK:   %cond:_(s1) = G_IMPLICIT_DEF
  ; CHECK:   %val_1:_(<32 x s8>) = G_IMPLICIT_DEF
  ; CHECK:   G_BRCOND %cond(s1), %bb.2
  ; CHECK:   G_BR %bb.1
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.2(0x80000000)
  ; CHECK:   %val_2:_(<32 x s8>) = G_IMPLICIT_DEF
  ; CHECK: bb.2:
  ; CHECK:   %phi:_(<32 x s8>) = G_PHI %val_2(<32 x s8>), %bb.1, %val_1(<32 x s8>), %bb.0
  ; CHECK:   %one:_(s8) = G_CONSTANT i8 1
  ; CHECK:   [[SEXT:%[0-9]+]]:_(s64) = G_SEXT %one(s8)
  ; CHECK:   %extract:_(s8) = G_EXTRACT_VECTOR_ELT %phi(<32 x s8>), [[SEXT]](s64)
  ; CHECK:   $b0 = COPY %extract(s8)
  ; CHECK:   RET_ReallyLR implicit $b0
  bb.0:
    successors: %bb.1(0x50000000), %bb.2(0x30000000)
    liveins: $x0, $x1
    %cond:_(s1) = G_IMPLICIT_DEF
    %val_1:_(<32 x s8>) = G_IMPLICIT_DEF
    G_BRCOND %cond(s1), %bb.2
    G_BR %bb.1
  bb.1:
    %val_2:_(<32 x s8>) = G_IMPLICIT_DEF
  bb.2:
    %phi:_(<32 x s8>) = G_PHI %val_2(<32 x s8>), %bb.1, %val_1(<32 x s8>), %bb.0
    %one:_(s8) = G_CONSTANT i8 1
    %extract:_(s8) = G_EXTRACT_VECTOR_ELT %phi(<32 x s8>), %one(s8)
    $b0 = COPY %extract
    RET_ReallyLR implicit $b0
...
---
name:            v4p0
alignment:       4
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: v4p0
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x50000000), %bb.2(0x30000000)
  ; CHECK:   liveins: $x0, $x1
  ; CHECK:   %ptr1:_(p0) = COPY $x1
  ; CHECK:   %ptr2:_(p0) = COPY $x0
  ; CHECK:   %cond:_(s1) = G_IMPLICIT_DEF
  ; CHECK:   %val_1:_(<4 x p0>) = G_LOAD %ptr1(p0) :: (load (<4 x p0>))
  ; CHECK:   [[UV:%[0-9]+]]:_(<2 x p0>), [[UV1:%[0-9]+]]:_(<2 x p0>) = G_UNMERGE_VALUES %val_1(<4 x p0>)
  ; CHECK:   G_BRCOND %cond(s1), %bb.2
  ; CHECK:   G_BR %bb.1
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.2(0x80000000)
  ; CHECK:   [[LOAD:%[0-9]+]]:_(<4 x s64>) = G_LOAD %ptr2(p0) :: (load (<4 x s64>))
  ; CHECK:   %val_2:_(<4 x p0>) = G_BITCAST [[LOAD]](<4 x s64>)
  ; CHECK:   [[UV2:%[0-9]+]]:_(<2 x p0>), [[UV3:%[0-9]+]]:_(<2 x p0>) = G_UNMERGE_VALUES %val_2(<4 x p0>)
  ; CHECK: bb.2:
  ; CHECK:   [[PHI:%[0-9]+]]:_(<2 x p0>) = G_PHI [[UV2]](<2 x p0>), %bb.1, [[UV]](<2 x p0>), %bb.0
  ; CHECK:   [[PHI1:%[0-9]+]]:_(<2 x p0>) = G_PHI [[UV3]](<2 x p0>), %bb.1, [[UV1]](<2 x p0>), %bb.0
  ; CHECK:   %phi:_(<4 x p0>) = G_CONCAT_VECTORS [[PHI]](<2 x p0>), [[PHI1]](<2 x p0>)
  ; CHECK:   %unmerge_1:_(<2 x p0>), %unmerge_2:_(<2 x p0>) = G_UNMERGE_VALUES %phi(<4 x p0>)
  ; CHECK:   $q0 = COPY %unmerge_1(<2 x p0>)
  ; CHECK:   $q1 = COPY %unmerge_2(<2 x p0>)
  ; CHECK:   RET_ReallyLR implicit $q0, implicit $q1
  bb.0:
    successors: %bb.1(0x50000000), %bb.2(0x30000000)
    liveins: $x0, $x1

    %ptr1:_(p0) = COPY $x1
    %ptr2:_(p0) = COPY $x0
    %cond:_(s1) = G_IMPLICIT_DEF
    %val_1:_(<4 x p0>) = G_LOAD %ptr1(p0) :: (load (<4 x p0>))
    G_BRCOND %cond(s1), %bb.2
    G_BR %bb.1
  bb.1:
    %val_2:_(<4 x p0>) = G_LOAD %ptr2(p0) :: (load (<4 x p0>))
  bb.2:
    %phi:_(<4 x p0>) = G_PHI %val_2(<4 x p0>), %bb.1, %val_1(<4 x p0>), %bb.0
    %unmerge_1:_(<2 x p0>), %unmerge_2:_(<2 x p0>) = G_UNMERGE_VALUES %phi(<4 x p0>)
    $q0 = COPY %unmerge_1(<2 x p0>)
    $q1 = COPY %unmerge_2(<2 x p0>)
    RET_ReallyLR implicit $q0, implicit $q1
